package com.itheima.dubbo.api.mongo.impl;

import com.itheima.dubbo.api.mongo.FocusUserApi;
import com.tanhua.model.mongo.FocusUser;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@DubboService
public class FocusUserApiImpl implements FocusUserApi {

    @Autowired
    private MongoTemplate mongoTemplate;


    @Override
    public void save(FocusUser focusUser) {
        mongoTemplate.save(focusUser);
    }

    @Override
    public void remove(Long userId, Long followUserId) {
        Query query = new Query(Criteria.where("userId").is(userId).and("followUserId").is(followUserId));
        mongoTemplate.remove(query,FocusUser.class);
    }
}
